home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / guile-ii.src / guile-ii / guile-src / guile-docs / user / scm.info-3 < prev    next >
Encoding:
GNU Info File  |  1995-06-08  |  48.7 KB  |  1,266 lines

  1. This is Info file scm.info, produced by Makeinfo-1.55 from the input
  2. file scm.texi.
  3.  
  4. 
  5. File: scm.info,  Node: Window Manipulation,  Next: Output,  Prev: Terminal Mode Setting,  Up: Curses
  6.  
  7. Window Manipulation
  8. -------------------
  9.  
  10.  - Function: newwin NLINES NCOLS BEGY BEGX
  11.      Create and return a new window with the given number of lines (or
  12.      rows), NLINES, and columns, NCOLS.  The upper left corner of the
  13.      window is at line BEGY, column BEGX.  If either NLINES or NCOLS is
  14.      0, they will be set to the value of `LINES'-BEGY and `COLS'-BEGX.
  15.      A new full-screen window is created by calling `newwin(0,0,0,0)'.
  16.  
  17.  - Function: subwin ORIG NLINES NCOLS BEGY BEGX
  18.      Create and return a pointer to a new window with the given number
  19.      of lines (or rows), NLINES, and columns, NCOLS.  The window is at
  20.      position (BEGY, BEGX) on the screen.  This position is relative to
  21.      the screen, and not to the window ORIG.  The window is made in the
  22.      middle of the window ORIG, so that changes made to one window will
  23.      affect both windows.  When using this routine, often it will be
  24.      necessary to call `touchwin' or `touchline' on ORIG before calling
  25.      `force-output'.
  26.  
  27.  - Function: close-port WIN
  28.      Deletes the window WIN, freeing up all memory associated with it.
  29.      In the case of sub-windows, they should be deleted before the main
  30.      window WIN.
  31.  
  32.  - Function: refresh
  33.  - Function: force-output WIN
  34.      These routines are called to write output to the terminal, as most
  35.      other routines merely manipulate data structures.  `force-output'
  36.      copies the window WIN to the physical terminal screen, taking into
  37.      account what is already there in order to minimize the amount of
  38.      information that's sent to the terminal (called optimization).
  39.      Unless `leaveok' has been enabled, the physical cursor of the
  40.      terminal is left at the location of window WIN's cursor.  With
  41.      `refresh', the number of characters output to the terminal is
  42.      returned.
  43.  
  44.  - Function: mvwin WIN Y X
  45.      Move the window WIN so that the upper left corner will be at
  46.      position (Y, X).  If the move would cause the window WIN to be off
  47.      the screen, it is an error and the window WIN is not moved.
  48.  
  49.  - Function: overlay SRCWIN DSTWIN
  50.  - Function: overwrite SRCWIN DSTWIN
  51.      These routines overlay SRCWIN on top of DSTWIN; that is, all text
  52.      in SRCWIN is copied into DSTWIN.  SRCWIN and DSTWIN need not be
  53.      the same size; only text where the two windows overlap is copied.
  54.      The difference is that `overlay' is non-destructive (blanks are
  55.      not copied), while `overwrite' is destructive.
  56.  
  57.  - Function: touchwin WIN
  58.  - Function: touchline WIN START COUNT
  59.      Throw away all optimization information about which parts of the
  60.      window WIN have been touched, by pretending that the entire window
  61.      WIN has been drawn on.  This is sometimes necessary when using
  62.      overlapping windows, since a change to one window will affect the
  63.      other window, but the records of which lines have been changed in
  64.      the other window will not reflect the change.  `touchline' only
  65.      pretends that COUNT lines have been changed, beginning with line
  66.      START.
  67.  
  68.  - Function: wmove WIN Y X
  69.      The cursor associated with the window WIN is moved to line (row) Y,
  70.      column X.  This does not move the physical cursor of the terminal
  71.      until `refresh' (or `force-output') is called.  The position
  72.      specified is relative to the upper left corner of the window WIN,
  73.      which is (0, 0).
  74.  
  75. 
  76. File: scm.info,  Node: Output,  Next: Input,  Prev: Window Manipulation,  Up: Curses
  77.  
  78. Output
  79. ------
  80.  
  81. These routines are used to "draw" text on windows
  82.  
  83.  - Function: display CH WIN
  84.  - Function: display STR WIN
  85.  - Function: wadd WIN CH
  86.  - Function: wadd WIN STR
  87.      The character CH or characters in STR are put into the window WIN
  88.      at the current cursor position of the window and the position of
  89.      WIN's cursor is advanced.  At the right margin, an automatic
  90.      newline is performed.  At the bottom of the scrolling region, if
  91.      scrollok is enabled, the scrolling region will be scrolled up one
  92.      line.
  93.  
  94.      If CH is a TAB, LFD, or backspace, the cursor will be moved
  95.      appropriately within the window WIN.  A LFD also does a
  96.      `wclrtoeol' before moving.  TAB characters are considered to be at
  97.      every eighth column.  If CH is another control character, it will
  98.      be drawn in the `C-x' notation.  (Calling `winch' after adding a
  99.      control character will not return the control character, but
  100.      instead will return the representation of the control character.)
  101.  
  102.      Video attributes can be combined with a character by or-ing them
  103.      into the parameter.  This will result in these attributes also
  104.      being set.  The intent here is that text, including attributes,
  105.      can be copied from one place to another using inch and display.
  106.      See `standout', below.
  107.  
  108.      *Note:* For `wadd' CH can be an integer and will insert the
  109.      character of the corresponding value.
  110.  
  111.  - Function: werase WIN
  112.      This routine copies blanks to every position in the window WIN.
  113.  
  114.  - Function: wclear WIN
  115.      This routine is like `werase', but it also calls *Note clearok:
  116.      Output Options Setting, arranging that the screen will be cleared
  117.      completely on the next call to `refresh' or `force-output' for
  118.      window WIN, and repainted from scratch.
  119.  
  120.  - Function: wclrtobot WIN
  121.      All lines below the cursor in window WIN are erased.  Also, the
  122.      current line to the right of the cursor, inclusive, is erased.
  123.  
  124.  - Function: wclrtoeol WIN
  125.      The current line to the right of the cursor, inclusive, is erased.
  126.  
  127.  - Function: wdelch WIN
  128.      The character under the cursor in the window WIN is deleted.  All
  129.      characters to the right on the same line are moved to the left one
  130.      position and the last character on the line is filled with a
  131.      blank.  The cursor position does not change.  This does not imply
  132.      use of the hardware "delete-character" feature.
  133.  
  134.  - Function: wdeleteln WIN
  135.      The line under the cursor in the window WIN is deleted.  All lines
  136.      below the current line are moved up one line.  The bottom line WIN
  137.      is cleared.  The cursor position does not change.  This does not
  138.      imply use of the hardware "deleteline" feature.
  139.  
  140.  - Function: winsch WIN CH
  141.      The character CH is inserted before the character under the
  142.      cursor.  All characters to the right are moved one SPC to the
  143.      right, possibly losing the rightmost character of the line.  The
  144.      cursor position does not change .  This does not imply use of the
  145.      hardware "insertcharacter" feature.
  146.  
  147.  - Function: winsertln WIN
  148.      A blank line is inserted above the current line and the bottom
  149.      line is lost.  This does not imply use of the hardware
  150.      "insert-line" feature.
  151.  
  152.  - Function: scroll WIN
  153.      The window WIN is scrolled up one line.  This involves moving the
  154.      lines in WIN's data structure.  As an optimization, if WIN is
  155.      stdscr and the scrolling region is the entire window, the physical
  156.      screen will be scrolled at the same time.
  157.  
  158. 
  159. File: scm.info,  Node: Input,  Next: Curses Miscellany,  Prev: Output,  Up: Curses
  160.  
  161. Input
  162. -----
  163.  
  164.  - Function: read-char WIN
  165.      A character is read from the terminal associated with the window
  166.      WIN.  Depending on the setting of `cbreak', this will be after one
  167.      character (`CBREAK' mode), or after the first newline (`NOCBREAK'
  168.      mode).  Unless `noecho' has been set, the character will also be
  169.      echoed into WIN.
  170.  
  171.      When using `read-char', do not set both `NOCBREAK' mode
  172.      (`nocbreak') and `ECHO' mode (`echo') at the same time.  Depending
  173.      on the state of the terminal driver when each character is typed,
  174.      the program may produce undesirable results.
  175.  
  176.  - Function: winch WIN
  177.      The character, of type chtype, at the current position in window
  178.      WIN is returned.  If any attributes are set for that position,
  179.      their values will be OR'ed into the value returned.
  180.  
  181.  - Function: getyx WIN
  182.      A list of the y and x coordinates of the cursor position of the
  183.      window WIN is returned
  184.  
  185. 
  186. File: scm.info,  Node: Curses Miscellany,  Prev: Input,  Up: Curses
  187.  
  188. Curses Miscellany
  189. -----------------
  190.  
  191.  - Function: wstandout WIN
  192.  - Function: wstandend WIN
  193.      These functions set the current attributes of the window WIN.  The
  194.      current attributes of WIN are applied to all characters that are
  195.      written into it.  Attributes are a property of the character, and
  196.      move with the character through any scrolling and insert/delete
  197.      line/character operations.  To the extent possible on the
  198.      particular terminal, they will be displayed as the graphic
  199.      rendition of characters put on the screen.
  200.  
  201.      `wstandout' sets the current attributes of the window WIN to be
  202.      visibly different from other text.  `wstandend' turns off the
  203.      attributes.
  204.  
  205.  - Function: box WIN VERTCH HORCH
  206.      A box is drawn around the edge of the window WIN.  VERTCH and
  207.      HORCH are the characters the box is to be drawn with.  If VERTCH
  208.      and HORCH are 0, then appropriate default characters, `ACS_VLINE'
  209.      and `ACS_HLINE', will be used.
  210.  
  211.      *Note:* VERTCH and HORCH can be an integers and will insert the
  212.      character (with attributes) of the corresponding values.
  213.  
  214.  - Function: unctrl C
  215.      This macro expands to a character string which is a printable
  216.      representation of the character C.  Control characters are
  217.      displayed in the `C-x' notation.  Printing characters are displayed
  218.      as is.
  219.  
  220. 
  221. File: scm.info,  Node: Sockets,  Prev: Curses,  Up: Packages
  222.  
  223. Sockets
  224. =======
  225.  
  226. These procedures (defined in `socket.c') provide a Scheme interface to
  227. most of the C "socket" library.  For more information on sockets, *Note
  228. Sockets: (libc)Sockets.
  229.  
  230. * Menu:
  231.  
  232. * Host Data::
  233. * Internet Addresses::
  234. * Socket::
  235.  
  236. 
  237. File: scm.info,  Node: Host Data,  Next: Internet Addresses,  Prev: Sockets,  Up: Sockets
  238.  
  239. Host Data, Network, Protocol, and Service Inquiries
  240. ---------------------------------------------------
  241.  
  242.  - Constant: af_inet
  243.  - Constant: af_unix
  244.      Integer family codes for Internet and Unix sockets, respectively.
  245.  
  246.  - Function: gethost HOST-SPEC
  247.  - Function: gethost
  248.      Returns a vector of information for the entry for `HOST-SPEC' or
  249.      the next entry if `HOST-SPEC' isn't given.  The information is:
  250.  
  251.        0. host name string
  252.  
  253.        1. list of host aliases strings
  254.  
  255.        2. integer address type (`AF_INET')
  256.  
  257.        3. integer size of address entries (in bytes)
  258.  
  259.        4. list of integer addresses
  260.  
  261.  - Function: sethostent STAY-OPEN
  262.  - Function: sethostent
  263.      Rewinds the host entry table back to the begining if given an
  264.      argument.  If the argument STAY-OPEN is `#f' queries will be be
  265.      done using `UDP' datagrams.  Otherwise, a connected `TCP' socket
  266.      will be used.  When called without an argument, the host table is
  267.      closed.
  268.  
  269.  - Function: getnet NAME-OR-NUMBER
  270.  - Function: getnet
  271.      Returns a vector of information for the entry for NAME-OR-NUMBER or
  272.      the next entry if an argument isn't given.  The information is:
  273.  
  274.        0. official network name string
  275.  
  276.        1. list of network aliases strings
  277.  
  278.        2. integer network address type (`AF_INET')
  279.  
  280.        3. integer network number
  281.  
  282.  - Function: setnetent STAY-OPEN
  283.  - Function: setnetent
  284.      Rewinds the network entry table back to the begining if given an
  285.      argument.  If the argument STAY-OPEN is `#f' the table will be
  286.      closed between calls to getnet.  Otherwise, the table stays open.
  287.      When called without an argument, the network table is closed.
  288.  
  289.  - Function: getproto NAME-OR-NUMBER
  290.  - Function: getproto
  291.      Returns a vector of information for the entry for NAME-OR-NUMBER or
  292.      the next entry if an argument isn't given.  The information is:
  293.  
  294.        1. official protocol name string
  295.  
  296.        2. list of protocol aliases strings
  297.  
  298.        3. integer protocol number
  299.  
  300.  - Function: setprotoent STAY-OPEN
  301.  - Function: setprotoent
  302.      Rewinds the protocol entry table back to the begining if given an
  303.      argument.  If the argument STAY-OPEN is `#f' the table will be
  304.      closed between calls to getproto.  Otherwise, the table stays
  305.      open.  When called without an argument, the protocol table is
  306.      closed.
  307.  
  308.  - Function: getserv NAME-OR-PORT-NUMBER PROTOCOL
  309.  - Function: getserv
  310.      Returns a vector of information for the entry for
  311.      NAME-OR-PORT-NUMBER and PROTOCOL or the next entry if arguments
  312.      aren't given.  The information is:
  313.  
  314.        0. official service name string
  315.  
  316.        1. list of service aliases strings
  317.  
  318.        2. integer port number
  319.  
  320.        3. protocol
  321.  
  322.  - Function: setservent STAY-OPEN
  323.  - Function: setservent
  324.      Rewinds the service entry table back to the begining if given an
  325.      argument.  If the argument STAY-OPEN is `#f' the table will be
  326.      closed between calls to getserv.  Otherwise, the table stays open.
  327.      When called without an argument, the service table is closed.
  328.  
  329. 
  330. File: scm.info,  Node: Internet Addresses,  Next: Socket,  Prev: Host Data,  Up: Sockets
  331.  
  332. Internet Addresses
  333. ------------------
  334.  
  335.  - Function: inet:string->address STRING
  336.      Returns the host address number (integer) for host STRING or `#f'
  337.      if not found.
  338.  
  339.  - Function: inet:address->string ADDRESS
  340.      Converts an internet (integer) address to a string in numbers and
  341.      dots notation.  This is an inverse function to inet:address.
  342.  
  343.  - Function: inet:network ADDRESS
  344.      Returns the network number (integer) specified from ADDRESS or
  345.      `#f' if not found.
  346.  
  347.  - Function: inet:local-network-address ADDRESS
  348.      Returns the integer for the address of ADDRESS within its local
  349.      network or `#f' if not found.
  350.  
  351.  - Function: inet:make-address NETWORK LOCAL-ADDRESS
  352.      Returns the Internet address of LOCAL-ADDRESS in NETWORK.
  353.  
  354. 
  355. File: scm.info,  Node: Socket,  Prev: Internet Addresses,  Up: Sockets
  356.  
  357. Socket
  358. ------
  359.  
  360.   When a port is returned from one of these calls it is unbuffered.
  361. This allows both reading and writing to the same port to work.  If you
  362. want buffered ports you can (assuming sock-port is a socket i/o port):
  363.      (require 'i/o-extensions)
  364.      (define i-port (duplicate-port sock-port "r"))
  365.      (define o-port (duplicate-port sock-port "w"))
  366.  
  367.  - Function: make-stream-socket FAMILY
  368.  - Function: make-stream-socket FAMILY PROTOCOL
  369.      Returns a `SOCK_STREAM' socket of type FAMILY using PROTOCOL.  If
  370.      FAMILY has the value `AF_INET', `SO_REUSEADDR' will be set.  The
  371.      integer argument PROTOCOL corresponds to the integer protocol
  372.      numbers returned (as vector elements) from `(getproto)'.  If the
  373.      PROTOCOL argument is not supplied, the default (0) for the
  374.      specified FAMILY is used.  SCM sockets look like ports opened for
  375.      neither reading nor writing.
  376.  
  377.  - Function: make-stream-socketpair FAMILY
  378.  - Function: make-stream-socketpair FAMILY PROTOCOL
  379.      Returns a pair (cons) of connected `SOCK_STREAM' (socket) ports of
  380.      type FAMILY using PROTOCOL.  Many systems support only socketpairs
  381.      of the `af-unix' FAMILY.  The integer argument PROTOCOL
  382.      corresponds to the integer protocol numbers returned (as vector
  383.      elements) from (getproto).  If the PROTOCOL argument is not
  384.      supplied, the default (0) for the specified FAMILY is used.
  385.  
  386.  - Function: socket:shutdown SOCKET HOW
  387.      Makes SOCKET no longer respond to some or all operations depending
  388.      on the integer variable HOW:
  389.  
  390.        0. Further input is disallowed.
  391.  
  392.        1. Further output is disallowed.
  393.  
  394.        2. Further input or output is disallowed.
  395.  
  396.      `Socket:shutdown' returns SOCKET if successful, `#f' if not.
  397.  
  398.  - Function: socket:connect INET-SOCKET HOST-NUMBER PORT-NUMBER
  399.  - Function: socket:connect UNIX-SOCKET PATHNAME
  400.      Returns SOCKET (changed to a read/write port) connected to the
  401.      Internet socket on host HOST-NUMBER, port PORT-NUMBER or the Unix
  402.      socket specified by PATHNAME.  Returns `#f' if not successful.
  403.  
  404.  - Function: socket:bind INET-SOCKET PORT-NUMBER
  405.  - Function: socket:bind UNIX-SOCKET PATHNAME
  406.      Returns INET-SOCKET bound to the integer PORT-NUMBER or the
  407.      UNIX-SOCKET bound to new socket in the file system at location
  408.      PATHNAME.  Returns `#f' if not successful. Binding a UNIX-SOCKET
  409.      creates a socket in the file system that must be deleted by the
  410.      caller when it is no longer needed (using `delete-file').
  411.  
  412.  - Function: socket:listen SOCKET BACKLOG
  413.      The bound (*note socket-bind: Sockets.) SOCKET is readied to
  414.      accept connections.  The positive integer BACKLOG specifies how
  415.      many pending connections will be allowed before further connection
  416.      requests are refused.  Returns SOCKET if successful, `#f' if not.
  417.  
  418.  - Function: socket:accept SOCKET
  419.      Accepts a connection on a bound, listening SOCKET.  Returns an
  420.      input/output port for the connection.
  421.  
  422.      For example:
  423.           (let ((sock (socket:bind (make-stream-socket af_inet) 8001)))
  424.             (socket:listen sock 5)
  425.             (do ((connection (socket:accept sock) (socket:accept sock)))
  426.                 (#f)
  427.               (handle-client-connection connection))))
  428.  
  429.      A type "socket-name" is used for inquiries about open sockets in
  430.      the following procedures:
  431.  
  432.  - Function: getsockname SOCKET
  433.      Returns the socket-name of SOCKET.  Returns `#f' if unsuccessful
  434.      or SOCKET is closed.
  435.  
  436.  - Function: getpeername SOCKET
  437.      Returns the socket-name of the socket connected to SOCKET.
  438.      Returns `#f' if unsuccessful or SOCKET is closed.
  439.  
  440.  - Function: socket-name:family SOCKET-NAME
  441.      Returns the integer code for the family of SOCKET-NAME.
  442.  
  443.  - Function: socket-name:port-number SOCKET-NAME
  444.      Returns the integer port number of SOCKET-NAME.
  445.  
  446.  - Function: socket-name:address SOCKET-NAME
  447.      Returns the integer Internet address for SOCKET-NAME.
  448.  
  449. 
  450. File: scm.info,  Node: Guile Facilities,  Next: Internals,  Prev: Packages,  Up: Top
  451.  
  452. Guile Facilities
  453. ****************
  454.  
  455.   Using SCM as a base, GUILE is a being developed to be a GNU scripting
  456. language.
  457.  
  458.   One design goal of GUILE is to fully support a large body of Emacs
  459. lisp code and a large population of Emacs lisp programmers.  GUILE
  460. accomplishes this goal by means of a translator that rewrites elisp
  461. programs as equivalent programs in extended GUILE Scheme.  We anticipate
  462. a port of the GNU Emacs built-ins to the GUILE environment.
  463.  
  464.   Tom Lord (Lord@cygnus.com) is coordinating GUILE's development.
  465.  
  466. * Menu:
  467.  
  468. * Locked Vectors::              You can define the layout of new types.
  469. * Exceptions::                  Cheap CATCH/THROW for errors and exits.
  470. * System Exceptions::           All error conditions can be caught by Scheme code.
  471. * Variables::                   First class locatives for top level variables.
  472. * User Defined Top Levels::     You can control the symbol->variable mapping.
  473. * Obarrays::                    First class tables for interning symbols.
  474. * Keywords::
  475. * Procedure Properties::
  476. * Dynamic Roots::               Creating uncapturable continuations.
  477. * Tcl Facilities::              Mutual calling between Tcl and Scheme.
  478. * Tk Facilities::               Accessing Tk from Scheme.
  479. * Gwish::                       A Wish-like application of Guile.
  480. * System Calls::                You can choose to ignore errors safely.
  481. * Gscsh::                       Shell and systems programming features.
  482.  
  483. 
  484. File: scm.info,  Node: Locked Vectors,  Next: Exceptions,  Prev: Guile Facilities,  Up: Guile Facilities
  485.  
  486. Locked Vectors
  487. ==============
  488.  
  489.   Locked vectors "lvectors" are a low level means by which Scheme code
  490. can define the representation of new types.  They are not themselves
  491. especially easy to use, but useful system can be built on top of them
  492. (for example, *note Records: (slib)Records.).
  493.  
  494.   User code should be selective about using lvector functions.  Lvectors
  495. are intended as the representation for user-defined types.  Types which
  496. otherwise have nothing to do with one another may have in common an
  497. lvector representation.  Using lvector functions in a context other than
  498. defining a new type or family of types is likely to be an unsupported
  499. violation of abstractions - something you generally only want to do
  500. when you are debugging or are willing to write *hacked up* (in the
  501. pejorative sense) code.
  502.  
  503.   Locked vectors have an internal representation similar to vectors.
  504. They are represented by a contiguous array in memory.  Access and
  505. modifications to fields can be done in constant time.  Like vectors,
  506. fields of a locked vector are addressed by integer addresses, based at
  507. 0.
  508.  
  509.   The 0 element of a locked vector is special.  It is called the "key
  510. vector".  It's use is comparable to that of type objects in other
  511. systems.
  512.  
  513.   The key vector must always be present (there is no such thing as a 0
  514. length lvector).  It must be a (normal) vector with at least as many
  515. elements as the lvector.  The elements of the key vector are used as
  516. keys which control access to the corresponding elements of the lvector.
  517.  
  518.   Keys are used this way: Procedures like lvector-ref and lvector-set!
  519. take a "key argument" in addition to the lvector and field index.  The
  520. key argument is compared to the indexed element of the key vector.  If
  521. they are the same (`eq?'), access to the lvector is granted.  If an
  522. access or modification fails because of an incorrect key, it may be
  523. retried.
  524.  
  525.   If element 0 of the key vector is itself an lvector, the first
  526. several elements of that lvector may be hook functions.  These hook
  527. functions are used to extend the behavior of built-in procedures.  Hook
  528. functions are explained in more detail at the end of this section.
  529.  
  530. * Menu:
  531.  
  532. * Lvector Procedures::
  533. * Key-Vector 0 Elements::
  534.  
  535. 
  536. File: scm.info,  Node: Lvector Procedures,  Next: Key-Vector 0 Elements,  Prev: Locked Vectors,  Up: Locked Vectors
  537.  
  538. Lvector Procedures
  539. ------------------
  540.  
  541.  - Function: lock-vector! VEC
  542.      Modify VEC so that it is a locked vector instead of a vector.
  543.      Once it is locked, ordinary vector operations no longer apply to
  544.      VEC, and `vector?' returns `#f' for VEC.
  545.  
  546.      In order to be locked, VEC must have at least one element.  The 0
  547.      element of VEC must be a key vector (see above).
  548.  
  549.      `lock-vector!' is currently the only way to construct a locked
  550.      vector.  However, the decision to create locked vectors by mutating
  551.      vectors is a dubious one.  Therefore, you should only use
  552.      lock-vector!  by wrapping it around a vector constructor, as in:
  553.  
  554.           (lock-vector! (apply vector (cons key-vector field-inits)))
  555.  
  556.      Following this convention will make it easier to replace
  557.      lock-vector!  with a more reasonable constructor later.
  558.  
  559.  - Function: unlock-vector! LVEC
  560.      Modify LVEC so that it is once again the vector passed to
  561.      `lock-vector!'.
  562.  
  563.      You should only use `unlock-vector!' for debugging.  It is not
  564.      guaranteed to be present in future versions of Guile.
  565.  
  566.  - Function: lvector-ref LVEC KEY INDEX
  567.      Return the INDEXth element of LVEC.
  568.  
  569.      If KEY matches the INDEXth element of the key vector of LVEC, then
  570.      the INDEXth element of LVEC is returned.  If the key does not
  571.      match, then the `ref-fn' hook is tried (hooks are documented
  572.      below).  If the INDEXth element can not be unlocked, an error is
  573.      signaled.
  574.  
  575.  - Function: lvector-set! LVEC KEY INDEX VAL
  576.      Set the INDEXth element of LVEC.
  577.  
  578.      If KEY matches the INDEXth element of the key vector of LVEC, then
  579.      the INDEXth element of LVEC is set.  If the key does not match,
  580.      then the `set-fn' hook is tried (see below).  If the INDEXth
  581.      element can not be unlocked, an error is signaled.
  582.  
  583.  - Function: lvector? OBJ
  584.      True if OBJ is indeed a locked vector.
  585.  
  586.  - Function: lvector-keys LVEC
  587.      Return the key vector of LVEC, a locked vector.
  588.  
  589.  - Function: lvector-accessor KEY-VEC INDEX
  590.      Return an accessor for KEY-VEC and INDEX.  This function is
  591.      defined as:
  592.  
  593.           (define (lvector-accessor keyvec index)
  594.              (lambda (lvec)
  595.                 (lvector-ref lvec (vector-ref keyvec index) index)))
  596.  
  597.      However, the built-in version returns an accessor function that is
  598.      faster than what the above code would return.
  599.  
  600.  - Function: lvector-modifier KEY-VEC INDEX
  601.      Return an modifier for KEY-VEC and INDEX.
  602.  
  603.      This function is defined as:
  604.  
  605.           (define (lvector-modifier keyvec index)
  606.              (lambda (lvec val)
  607.                 (lvector-set!  lvec (vector-ref keyvec index) index val)))
  608.  
  609.      However, the built-in version returns an modifier function that is
  610.      faster than what the above code would return.
  611.  
  612.  - Function: lvector-isa? LVECTOR KEY-VECTOR
  613.      Return `#t' if LVECTOR's 0th element is `eq?' to KEY-VECTOR.
  614.  
  615.      If KEY-VECTOR is not equal to element 0, lvector-isa? may yet
  616.      return a true value - it returns the (arbitrary) return value of
  617.      of the isa-fn?, if that hook is provided.
  618.  
  619. 
  620. File: scm.info,  Node: Key-Vector 0 Elements,  Prev: Lvector Procedures,  Up: Locked Vectors
  621.  
  622. Key-Vector 0 Elements
  623. ---------------------
  624.  
  625.   The first element of the key vector is special.  It may refer to a
  626. number of hook functions used by the lvector procedures and other parts
  627. of the run time system.
  628.  
  629.   The 0 element of a key vector may (optionally) be an lvector called
  630. "the type lvector".  A type lvector is characterized by having as a key
  631. the procedure `lvector-ref' for elements at offsets where hook
  632. functions are expected.
  633.  
  634.   The hook function offsets are bound to the variables
  635. LVECTOR-HOOK-<FN>; so the REF-FN is at the offset bound to
  636. LVECTOR-REF-FN, the SET-FN to LVECTOR-SET-FN and so on.
  637.  
  638.   The order and position of the hooks is explicitly specified:
  639.  
  640.   1. ref-fn
  641.  
  642.   2. set-fn
  643.  
  644.   3. print-fn
  645.  
  646.   4. equal-fn
  647.  
  648.   5. isa-fn
  649.  
  650.   Here is how they are used:
  651.  
  652.  - Hook: ref-fn LVEC KEY INDEX
  653.      This function is called by `lvector-ref' for illegal keys.  A KEY
  654.      is illegal if it is not `eq?' to the INDEXth key of the key vector
  655.      of LVEC.  The `ref-fn' hook may return a value for `lvector-ref'
  656.      or can signal an error.  The default action is to signal an error.
  657.  
  658.  - Hook: set-fn LVEC KEY INDEX VAL
  659.      This function is called by `lvector-set!' for illegal keys.  This
  660.      hook can interpret the assignment arbitrarily, including signal an
  661.      error.  It can return a value for `lvector-set!'.  The default
  662.      action is to signal an error.
  663.  
  664.  - Hook: print-fn LVEC PORT WRITING?
  665.      This function, if present, is called whenever the object is
  666.      printed.  It should print the object on PORT.  WRITING?, if `#t',
  667.      indicates that the value is being `write'n; if `#f' - `display'ed.
  668.      The print function should return a true value if it succeeds.  It
  669.      should return `#f' for objects which it can not print.  In that
  670.      case, a generic print routine for "unknown objects" is used. The
  671.      default action (if no PRINT-FN is supplied) is to print something
  672.      like: `#<locked-vector 0x7856af8>'.
  673.  
  674.  - Predicate: equal-fn? LVEC LVEC2
  675.      If present, called to evaluate `(equal? lvec lvec2)'.  The default
  676.      action is a member-wise comparison of the two lvecs.  Note that
  677.      the first argument to `equal?' chooses the hook function.
  678.  
  679.  - Predicate: isa-fn? LVEC KEY-VECTOR
  680.      If present, this may be called by `lvector-isa?'.
  681.  
  682.      If KEY-VECTOR is eq to lvecs key-vector, then `lvector-isa?'
  683.      simply returns `#t'.  If not, if the isa-fn is present, it is
  684.      called.  The default action is to return `#f'.
  685.  
  686.   Any of the hooks may be `#f' specifying that the default action
  687. should be used.
  688.  
  689.  - Variable: lvector-hook-slots
  690.      The variable `lvector-hook-slots' is bound to the number of hook
  691.      slots looked for by the run time system.  A type lvector should
  692.      have at least that many fields.
  693.  
  694.   Here is an illustration of the construction of lvectors.  Note that
  695. two lvectors are built - one to hold the hook functions, and then the
  696. one for "user code".
  697.  
  698.      ;; Create a key vector compatible with the run-time system's
  699.      ;; way of finding hook functions.
  700.      ;;
  701.      (define a-type-keyvec
  702.        ;; The run-time system uses procedure lvector-ref as the key
  703.        ;; to access hook functions.  You could define type keyvecs
  704.        ;; with more elements if you had a use for them.
  705.        ;;
  706.        (make-vector lvector-hook-slots lvector-ref))
  707.      
  708.      ;; Lock up user-provided hook functions for the run-time system.
  709.      ;; A var-args implementation would make more sense -- it would
  710.      ;; make it easier to add hooks later.  The example is written
  711.      ;; this way just to provide a reference for the proper order
  712.      ;; of hook functions within the lvector.
  713.      ;;
  714.      (define (make-type-lvector ref-hook set-hook print-hook
  715.                                 equal-hook isa-hook)
  716.        (lock-vector! (vector a-type-keyvec
  717.                              ref-hook
  718.                              set-hook
  719.                              print-hook
  720.                              equal-hook
  721.                              isa-hook)))
  722.      
  723.      ;; Turn a list of field keys into a key vector of a particular
  724.      ;; type:
  725.      ;;
  726.      (define (make-key-vector type-lvector . field-keys)
  727.        (apply vector (cons type-lvector field-keys)))
  728.      
  729.      ;; Turn a key-vector and list of field initializers into
  730.      ;; a locked vector.  Note that lock-vector! does some error
  731.      ;; checking on the lengths of the input arguments.
  732.      ;;
  733.      (define (make-object key-vector . field-inits)
  734.        (lock-vector! (apply (vector (cons key-vector field-inits)))))
  735.  
  736. 
  737. File: scm.info,  Node: Exceptions,  Next: System Exceptions,  Prev: Locked Vectors,  Up: Guile Facilities
  738.  
  739. Exceptions
  740. ==========
  741.  
  742.   These are the low level entry points to exceptions.  Individual
  743. subsystems may define their own uses for exceptions.
  744.  
  745.  - Function: catch KEY THUNK HANDLER
  746.      Invoke THUNK in the dynamic context of HANDLER for excpetions
  747.      matching KEY.  If thunk throws to the symbol KEY, then HANDLER is
  748.      invoked this way:
  749.  
  750.           (handler key args ...)
  751.  
  752.      KEY may be a symbol.  In that case, THUNK takes no arguments.  If
  753.      THUNK returns normally, that is the return value of `catch'.
  754.  
  755.      Handler is invoked outside the scope of its own `catch'.  If
  756.      HANDLER against throws to the same key, a new handler from further
  757.      up the call chain is invoked.
  758.  
  759.      If the key is #t, then a throw to any symbol will match this call
  760.      to `catch'.
  761.  
  762.      Key may also be the value `#f'.  In that case, THUNK takes one
  763.      argument which will be passed a "jump buffer object".  A jump
  764.      buffer object may be used as the key argument to `throw' to throw
  765.      to a specific `catch' without an intervening search for a symbolic
  766.      key.
  767.  
  768.  - Function: throw KEY ARGS ...
  769.  - Function: throw KEY
  770.      Invoke the catch form matching KEY, passing ARGS to the HANDLER.
  771.  
  772.      If the key is a symbol it will match catches of the same symbol or
  773.      of #t.  If no catch matches, the `throw-default-handler' property
  774.      of the key is checked.  If it is bound to a procedure, that
  775.      procedure is called:
  776.  
  777.           (handler key args ...)
  778.  
  779.      That procedure is called the "default handler".
  780.  
  781.      If there is no handler at all, or if the default handler returns
  782.      to its caller, an error is signaled.
  783.  
  784.      It is traditional in Scheme to implement exception systems using
  785.      `call-with-current-continuation', but his has not been done, for
  786.      performance reaons.  The implementation of
  787.      `call-with-current-continuation' is a stack copying implementation.
  788.      This allows it to interact well with ordinary C code.
  789.      Unfortunately, a stack-copying implementation can be slow -
  790.      creating a new continuation involves a block copy of the stack.
  791.  
  792.      Instead of using `call-with-current-continuation', the exception
  793.      primitives are implemented as built-ins that take advantage of the
  794.      *upward only* nature of exceptions.
  795.  
  796. 
  797. File: scm.info,  Node: System Exceptions,  Next: Variables,  Prev: Exceptions,  Up: Guile Facilities
  798.  
  799. System Exceptions
  800. =================
  801.  
  802.   These two expressions are equivalent:
  803.  
  804.      (error arg ...)
  805.      
  806.      (throw 'error arg ...)
  807.  
  808.   The following are the names of excpetions that may be thrown by the
  809. interpreter itself.
  810.  
  811.      ARGn        "Wrong type argument"
  812.      ARG1        "Wrong type argument in position 1"
  813.      ARG2        "Wrong type argument in position 2"
  814.      ARG3        "Wrong type argument in position 3"
  815.      ARG4            "Wrong type argument in position 4"
  816.      ARG5        "Wrong type argument in position 5"
  817.      WNA        "Wrong number of arguments"
  818.      OVFLOW        "Numerical overflow"
  819.      OUTOFRANGE    "Argument out of range"
  820.      NALLOC        "Could not allocate"
  821.      HUP_SIGNAL    "hang-up"
  822.      INT_SIGNAL    "user interrupt"
  823.      FPE_SIGNAL    "arithmetic error"
  824.      BUS_SIGNAL    "bus error"
  825.      SEGV_SIGNAL    "segmentation violation"
  826.      ALRM_SIGNAL    "alarm"
  827.      
  828.      read-sharp-error
  829.  
  830. 
  831. File: scm.info,  Node: Variables,  Next: User Defined Top Levels,  Prev: System Exceptions,  Up: Guile Facilities
  832.  
  833. Variables
  834. =========
  835.  
  836.   All top level bindings are stored in locations called "variables".
  837. Variables are first class objects.
  838.  
  839.  - Function: make-variable INIT
  840.  - Function: make-variable INIT NAME-HINT
  841.      Return a new variable, bound to INIT.
  842.  
  843.      The optional NAME-HINT is a symbolic name for the variable.  It
  844.      will be used in some error messages relating to the variable.
  845.  
  846.  - Function: variable-ref VARIABLE
  847.      Return the current binding of VARIABLE.
  848.  
  849.      It is an error to call `variable-ref' on a variable which is
  850.      unbound.
  851.  
  852.  - Function: variable-set! VARIABLE VALUE
  853.      Modify the binding of VARIABLE.
  854.  
  855.  - Function: builtin-variable NAME
  856.      Return the built-in variable for named NAME.  NAME must be a
  857.      symbol.
  858.  
  859.      Even symbols with no top level bindings have built-in variables.
  860.      There is an unbounded supply of undefined variables.
  861.  
  862.  - Predicate: variable? OBJ
  863.      Return `#t' if OBJ is a variable;  `#f' otherwise.
  864.  
  865.  - Predicate: variable-bound? VAR
  866.      Return `#t' if VAR is a bound variable; `#f' otherwise.
  867.  
  868.  - Function: make-undefined
  869.  - Function: make-undefined NAME-HINT
  870.      Return a new variable, initially unbound.
  871.  
  872.      The optional NAME-HINT a symbolic name for the variable.  It will
  873.      be used in some error messages relating to the variable.
  874.  
  875. 
  876. File: scm.info,  Node: User Defined Top Levels,  Next: Obarrays,  Prev: Variables,  Up: Guile Facilities
  877.  
  878. User Defined Top Levels
  879. =======================
  880.  
  881.   Low level support is provided for multiple top levels.  This procedure
  882. should only be used advisadly.  Most people should stick to the "user
  883. level module system interface".
  884.  
  885.  - Function: eval2 FORM ENV-FN
  886.      Evaluate FORM in the top level environment described by ENV-FN.
  887.  
  888.      ENV-FN is called this way:
  889.           (env-fn name defining)
  890.  
  891.      Return a variable object for the symbol NAME.  Returning `#f'
  892.      indicates that NAME has no binding.
  893.  
  894.      The boolean DEFINING is `#t', then the lookup is for a `define'
  895.      form or the equivalent - a new variable may be created if none
  896.      already exists.
  897.  
  898.      If `#f', then the request should not create a new binding.
  899.  
  900. 
  901. File: scm.info,  Node: Obarrays,  Next: Keywords,  Prev: User Defined Top Levels,  Up: Guile Facilities
  902.  
  903. Obarrays
  904. ========
  905.  
  906.   An "obarray" is an ordinary Scheme vector, used in a particular way.
  907. It represents two mapping: a mapping of strings to symbols, and a
  908. mapping of symbols to arbitrary values.
  909.  
  910.   To initialize an obarray, create a vector of any non-0 size, filled
  911. with the empty list.  Thereafter, referring to the contents of the
  912. vector yields unspecified values.  (You might be able guess the detailed
  913. representation of obarrays by examining the array, but if your code
  914. depends on that representation, it might easily break in future versions
  915. of Guile.)
  916.  
  917.  - Function: intern-string OBARRAY NAME
  918.      Return the SYMBOL bound to the stringNAME in OBARRAY.
  919.  
  920.      If there is no such symbol, a new SYMBOL is allocated.  OBARRAY
  921.      may be `#f' which guarantees that a new SYMBOL is returned.
  922.  
  923.  - Function: intern-symbol OBARRAY SYMBOL
  924.      Add SYMBOL to OBARRAY.  If SYMBOL is already present, this has no
  925.      effect.
  926.  
  927.      After this addition, SYMBOL is the symbol binding of its name.
  928.      That is, even if another symbol of the same name was previously
  929.      interned in OBARRAY, SYMBOL becomes the binding of that name after
  930.      intern-symbol.  (This does not mean that the previous symbol is
  931.      removed from the OBARRAY).
  932.  
  933.  - Function: symbol-interned? OBARRAY SYMBOL
  934.      Return `#t' if SYMBOL is in OBARRAY.
  935.  
  936.  - Function: symbol-bound? OBARRAY SYMBOL
  937.  - Function: symbol-binding OBARRAY SYMBOL
  938.  - Function: symbol-set! OBARRAY SYMBOL VALUE
  939.      A SYMBOL in an OBARRAY may be bound arbitrarily.  The binding may
  940.      be changed.  When first interned, a symbol is unbound.
  941.  
  942. 
  943. File: scm.info,  Node: Keywords,  Next: Procedure Properties,  Prev: Obarrays,  Up: Guile Facilities
  944.  
  945. Keywords
  946. ========
  947.  
  948.   A "keyword" is a self-evaluating symbol-like object with a convenient
  949. read syntax.
  950.  
  951.              (keyword? :keyword) => #t
  952.  
  953.  - Function: make-keyword SYMBOL
  954.      Construct a keyword form a symbol.
  955.  
  956.      The first character of the symbol's name must be '-'.
  957.  
  958.                   (make-keyword '-command) => :command
  959.  
  960.  - Function: keyword? OBJ
  961.      Return `#f' unless OBJ is a keyword object.
  962.  
  963.  - Function: keyword->symbol KEYWORD
  964.      Return the symbol that corresponds to a keyword.
  965.  
  966.                   (keyword->symbol :text) => -text
  967.  
  968. 
  969. File: scm.info,  Node: Procedure Properties,  Next: Dynamic Roots,  Prev: Keywords,  Up: Guile Facilities
  970.  
  971. Procedure Properties
  972. ====================
  973.  
  974.   Procedures created using "define" or "lambda" have a binding slot
  975. which you can use arbitrarily.  Many parts of the system will presume
  976. that this slot will contain a (possible empty) assoc list, keyed by
  977. symbols (`procedure properties').  If your procedure will be
  978. manipulated by a part of the system which is documented as using
  979. property lists, you should follow the convention, and use a unique
  980. prefix for all property names that you define.  Procedures which do not
  981. escape to such parts of the system can hve any value at all in their
  982. binding slot.
  983.  
  984.   It is an arbitrary restriction that (some) built-in procedures lack a
  985. binding slot.  This ought to be fixed.  The reason it hasn't been fixed
  986. already is that the representation of the binding slot has to be chosen
  987. carefully for built-in procedure types.
  988.  
  989.  - Function: procedure-properties PROCEDURE
  990.  - Function: set-procedure-properties! PROCEDURE VALUE
  991.      Return or set the value held in a procedures binding slow.
  992.  
  993.  - Function: procedure-property PROC KEY
  994.  - Function: procedure-assoc PROC KEY
  995.  - Function: procedure-putprop! PROC KEY VALUE
  996.      Retrieve or get the binding of a particular procedure property.
  997.  
  998.      These functions assume that the binding slot of the procedure
  999.      holds an assoc list.
  1000.  
  1001.      `procedure-property' returns the binding of the property while
  1002.      `procedure-assoc' returns the key-value pair that holds the
  1003.      binding.
  1004.  
  1005. 
  1006. File: scm.info,  Node: Dynamic Roots,  Next: Tcl Facilities,  Prev: Procedure Properties,  Up: Guile Facilities
  1007.  
  1008. Dynamic Roots
  1009. =============
  1010.  
  1011.   A "dynamic root" is a root frame of Scheme evaluation.  The top-level
  1012. repl, for example, is an instance of a dynamic root.
  1013.  
  1014.   Each dynamic root has its own chain of dynamic-wind information.  Each
  1015. has its own set of continuations, jump-buffers, and pending CATCH
  1016. statements which are inaccessible from the dynamic scope of any other
  1017. dynamic root.
  1018.  
  1019.   In a thread-based system, each thread has its own dynamic root.
  1020. Therefore, continuations created by one thread may not be invoked by
  1021. another. [Thread support is not yet fully implemented.]
  1022.  
  1023.   Even in a single-threaded system, it is sometimes useful to create a
  1024. new dynamic root.  For example, if you want to apply a procedure, but to
  1025. not allow that procedure to capture the current continuation, calling
  1026. the procedure under a new dynamic root will do the job.
  1027.  
  1028.  - Function: call-with-dynamic-root THUNK ERROR-THUNK
  1029.      Evaluate (THUNK) in a new dynamic context, returning its value.
  1030.  
  1031.      If an error occurs during evaluation, call error-thunk, passing it
  1032.      an error code describing the condition.  [Error codes are currently
  1033.      meaningless integers.  In the future, real values will be
  1034.      specified.] If this happens, the error-thunk is called outside the
  1035.      scope of the new root - it is called in the same dynamic context
  1036.      in which call-with-dynamic-root was evaluated.
  1037.  
  1038.      If THUNK captures a continuation, the continuation is rooted at
  1039.      the call to THUNK.  In particular, the call to
  1040.      call-with-dynamic-root is not captured.  Therefore,
  1041.      call-with-dynamic-root always returns at most one time.
  1042.  
  1043.      Before calling THUNK, the dynamic-wind chain is un-wound back to
  1044.      the root and a new chain started for THUNK.  Therefore, this call
  1045.      may not do what you expect:
  1046.  
  1047.           ;; Almost certainly a bug:
  1048.           (call-with-output-to-port
  1049.            some-port
  1050.           
  1051.            (lambda ()
  1052.              (call-with-dynamic-root
  1053.               (lambda ()
  1054.                 (display 'fnord)
  1055.                 (newline))
  1056.               (lambda (errcode) errcode))))
  1057.  
  1058.      The problem is, on what port will `fnord\n' be displayed?  You
  1059.      might expect that because of the `call-with-input-from-port' that
  1060.      it will be displayed on the port bound to `some-port'.  But it
  1061.      probably won't - before evaluating the thunk, dynamic winds are
  1062.      unwound, including those created by `call-with-input-from-port'.
  1063.      So, the standard output port will have been re-set to its default
  1064.      value before `display' is evaluated.
  1065.  
  1066.      (This function was added to Guile mostly to help calls to
  1067.      functions in C libraries that can not tolerate non-local exits or
  1068.      calls that return multiple times.  If such functions call back to
  1069.      the interpreter, it should be under a new dynamic root.)
  1070.  
  1071.  - Function: dynamic-root
  1072.      Return an object representing the current dynamic root.
  1073.  
  1074.      These objects are only useful for comparison using `eq?'.  They
  1075.      are currently represented as numbers, but your code should in no
  1076.      way depend on this.
  1077.  
  1078. 
  1079. File: scm.info,  Node: Tcl Facilities,  Next: Tk Facilities,  Prev: Dynamic Roots,  Up: Guile Facilities
  1080.  
  1081. Tcl Facilities
  1082. ==============
  1083.  
  1084.   If you have Tcl extension modules written in C, these can be accessed
  1085. from Guile programs.  If you have an application that uses the Tcl
  1086. interpreter, you can use Guile to define new modules for it - modules
  1087. that can be loaded without having to re-compile.
  1088.  
  1089.   Documented here are the low-level facilities linking Tcl to Guile.  In
  1090. the future, a friendlier Scheme interface will be provided in preference
  1091. to these entry points.
  1092.  
  1093.  - Function: tcl-create-interp
  1094.      Return a new Tcl interpreter object.
  1095.  
  1096.      An interpreter object is a namespace of functions and variables
  1097.      managed by modules that use the Tcl calling conventions.
  1098.  
  1099.  - Function: tcl-global-eval INTERPRETER STRING
  1100.      Evaluate a string according to Tcl's evaluation rules.
  1101.  
  1102.      INTERPRETER must be an object returned by `tcl-create-interp'.
  1103.  
  1104.      The return value is an integer/string pair.  The integer is the Tcl
  1105.      status code, the string is the Tcl result.
  1106.  
  1107.      This is not the way to call a Tcl command.  See the functions
  1108.      `tcl-command' and `tcl-apply-command'.  Using those functions is
  1109.      faster.
  1110.  
  1111.      N.B.: by default, most built-in Tcl commands are absent in Guile.
  1112.      Consequently, most Tcl programs will not run.  However, facilities
  1113.      exist so that you can link all of libtcl with Guile programs - in
  1114.      which case all the usual built-in commands will be present.  [add
  1115.      reference!]
  1116.  
  1117.  - Function: tcl-get-int INTERPRETER STRING
  1118.  - Function: tcl-get-double INTERPRETER STRING
  1119.  - Function: tcl-get-boolean INTERPRETER STRING
  1120.      Convert strings to Scheme types according to the conventions of
  1121.      Tcl.
  1122.  
  1123.  - Function: tcl-split-list INTERPRETER STRING
  1124.      Split a Tcl-style "list" (a string following Tcl's list syntax)
  1125.      into a list.
  1126.  
  1127.  - Function: tcl-merge INTERPRETER LIST
  1128.      Combine a list of strings into a string following Tcl's list
  1129.      syntax.
  1130.  
  1131.  - Function: tcl-create-command INTERPRETER NAME PROCEDURE
  1132.      Define a new Tcl command which is recognized by the Tcl evaluator.
  1133.  
  1134.      INTERPRETER must be an object returned by `tcl-create-command'.
  1135.  
  1136.      NAME must be a string which is a valid Tcl identifier.
  1137.  
  1138.      PROCEDURE may be any Scheme procedure object.
  1139.  
  1140.      When the Tcl evaluator invokes the new command, PROCEDURE is
  1141.      called with as many arguments as were passed to the Tcl command.
  1142.      The arguments are all passed as strings.
  1143.  
  1144.      The return value of PROCEDURE is used as the Tcl result.  The
  1145.      return value of PROCEDURE determines the Tcl return value
  1146.      according to these rules:
  1147.  
  1148.           if PROCEDURE returns:      the Tcl result is:   and Tcl status is:
  1149.           __________________________________________________________________
  1150.           
  1151.           string (e.g. "foo")           that string ("foo")       TCL_OK
  1152.           
  1153.           integer (e.g. 1)              the empty string          the int
  1154.                                                                       (1)
  1155.           
  1156.           an int/string pair            the string                the int
  1157.           (e.g. (1 . "bogus frob"))        ("bogus frob")             (1)
  1158.  
  1159.  - Function: tcl-delete-command INTERPRETER NAME
  1160.      Remove the named command from a Tcl interpreter.
  1161.  
  1162.  - Function: tcl-trace-var2 INTERPRETER NAME INDEX FLAGS PROCEDURE
  1163.  - Function: tcl-untrace-var2 INTERPRETER NAME INDEX FLAGS PROCEDURE
  1164.      Add a callback to a Tcl variable.
  1165.  
  1166.      NAME is the name of the variable.
  1167.  
  1168.      INDEX is the subscript of the variable, or `#f' for a scalar.
  1169.  
  1170.      After `tcl-trace-var2', modifications to the named variable or
  1171.      array position cause procedure to be called with four arguments: a
  1172.      tcl interpreter, the variable being modified, an index into the
  1173.      named variable (possible the empty string), and an integer of
  1174.      flags.
  1175.  
  1176.  - Function: tcl-set-var2 INTERPRETER NAME INDEX VALUE FLAGS
  1177.  - Function: tcl-get-var2 INTERPRETER NAME INDEX FLAGS
  1178.      Set or return the current value of a Tcl variable.
  1179.  
  1180.   Symbolic names for Tcl flags are provided in the source file Gtcl.scm
  1181. and are the same as their C counterparts.  The procedure `flags' is
  1182. used to combine flags.  For example:
  1183.  
  1184.   (flags TCL_TRACE_READS TCL_TRACE_WRITES TCL_TRACE_UNSETS)
  1185.  
  1186.   Tcl commands can be invoked from Scheme directly, without having to
  1187. use the Tcl evaluator:
  1188.  
  1189.  - Function: tcl-command INTERPRETER NAME
  1190.      Return an object representing the named command (or #f if none is
  1191.      defined).
  1192.  
  1193.  - Function: tcl-apply-command COMMAND ARGS
  1194.      Apply Tcl command COMMAND to the list of strings ARGS.
  1195.  
  1196.      COMMAND should be an object returned by `tcl-command'.
  1197.  
  1198.      ARGS should be a list of arguments.
  1199.  
  1200.      The return value is an integer/string pair.  The integer is a Tcl
  1201.      return code, the string the Tcl result.
  1202.  
  1203.      The arguments can be of several types but must ultimately be
  1204.      converted to strings because of the way Tcl and Tk work
  1205.      internally.  Types are converted this way:
  1206.  
  1207.             ;;----------------------------------------
  1208.             ;; Argument             Converted argument
  1209.             ;;----------------------------------------
  1210.               123                     "123"
  1211.               123.34                  "123.34"
  1212.               "a-string"              "a-string"
  1213.               'a-symbol               "a-symbol"
  1214.               :keyword                "-keyword"
  1215.               #t                      "1"
  1216.               #f                      "0"
  1217.               (lambda (...) ...)      "*__guile#234"
  1218.  
  1219.      The automatic conversion of a procedure works this way.  First, a
  1220.      new Tcl name is generated for the procedure and a Tcl command with
  1221.      that name is defined.  When evaluated, the Tcl command calls the
  1222.      Scheme procedure.  Second, if the procedure has a property defined
  1223.      called 'tcl-calling-convention, and if that is bound to a string,
  1224.      then that string is appended to the name with an intervening
  1225.      space.  For example, if a procedure's properties bind
  1226.      'tcl-calling-convention to "%x %y", then the name is appended and
  1227.      winds up like "__guile#234 %x %y".  Finally, an asterix is
  1228.      prepended to the name (e.g. "*__guile#234 %x %y").
  1229.  
  1230.      In the GNU modified version of Tcl/Tk, an asterix prepended to a
  1231.      command name has special meaning if the name is passed as a
  1232.      "-command" or similar configuration parameter to a widget, or if
  1233.      passed as the command argument to a "bind" operation.  In that
  1234.      case, the command is renamed to a canonical name that is unique to
  1235.      the widget or binding sequence (overwriting any previous
  1236.      definition).  If the widget or binding sequence is later deleted,
  1237.      so is the canonicalized command.  This is an extremely twisted way
  1238.      to trick Tcl into managing anonymous Scheme procedures with
  1239.      acceptable semantics (e.g., without core leaks and without
  1240.      requiring Scheme programmers to invent liveness for anonymous
  1241.      procedures they'd otherwise drop).
  1242.  
  1243. 
  1244. File: scm.info,  Node: Tk Facilities,  Next: Gwish,  Prev: Tcl Facilities,  Up: Guile Facilities
  1245.  
  1246. Tk Facilities
  1247. =============
  1248.  
  1249.   So that Tk widgets can be used form Scheme, Guile provides the
  1250. following functions:
  1251.  
  1252.  - Function: tk-init-main-window INTERPRETER DISPLAY NAME CLASS
  1253.      Initialize a Tcl interpreter as a Tk main window.
  1254.  
  1255.      DISPLAY, NAME, and CLASS must all be strings.
  1256.  
  1257.  - Function: tk-do-one-event FLAGS
  1258.      Process one window system event.
  1259.  
  1260.      Symbolic definitions for FLAGS are provided in Gtk.scm and have
  1261.      the same name as their C counterparts.
  1262.  
  1263.  - Function: tk-main-loop
  1264.      Process window events until no windows remain.
  1265.  
  1266.